﻿using System;
using System.Html;
using System.Html.DOM;

namespace jQueryLib
{
    public partial class JQueryInstance
    {
        /// <summary>
        /// Register a handler to be called when Ajax requests complete. This is an Ajax Event.
        /// </summary>
        /// <param name="callback">void function(event, xhr, settings)</param>
        /// <returns></returns>
        public abstract JQueryInstance AjaxComplete(Action<JQueryEvent, XmlHttpRequest, AjaxSettings> callback);

        /// <summary>
        /// Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event.
        /// </summary>
        /// <param name="callback">void function(event, jqXHR, settings, thrownError)</param>
        /// <returns></returns>
        public abstract JQueryInstance AjaxError(Action<JQueryEvent, JQXmlHttpRequest, AjaxSettings, Exception> callback);

        /// <summary>
        /// Attach a function to be executed before an Ajax request is sent. This is an Ajax Event.
        /// </summary>
        /// <param name="callback">void function(event, jqXHR, settings)</param>
        /// <returns></returns>
        public abstract JQueryInstance AjaxSend(Action<JQueryEvent, JQXmlHttpRequest, AjaxSettings> callback);

        /// <summary>
        /// Register a handler to be called when the first Ajax request begins. This is an Ajax Event.
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        public abstract JQueryInstance AjaxStart(Action callback);

        /// <summary>
        /// Register a handler to be called when all Ajax requests have completed. This is an Ajax Event.
        /// </summary>
        /// <returns></returns>
        public abstract JQueryInstance AjaxStop(Action callback);

        /// <summary>
        /// Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event.
        /// </summary>
        /// <param name="callback">void function(event, jqXHR, settings)</param>
        /// <returns></returns>
        public abstract JQueryInstance AjaxSuccess(Action<JQueryEvent, XmlHttpRequest, AjaxSettings> callback);

        /// <summary>
        /// Load data from the server and place the returned HTML into the matched element.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public abstract JQueryInstance load(string url);

        /// <summary>
        /// Load data from the server and place the returned HTML into the matched element.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="complete">function(responseText, status, jqXHR)</param>
        /// <returns></returns>
        public abstract JQueryInstance load(string url, Action<string, string, JQXmlHttpRequest> complete);

        /// <summary>
        /// Load data from the server and place the returned HTML into the matched element.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="data"></param>
        /// <param name="complete">function(responseText, status, jqXHR)</param>
        /// <returns></returns>
        public abstract JQueryInstance load(string url, object data, Action<string, string, JQXmlHttpRequest> complete);
    }

    public partial class JQuery
    {
        /// <summary>
        /// Perform an asynchronous HTTP (Ajax) request.
        /// </summary>
        public static JQXmlHttpRequest Ajax()
        {
            return null;
        }

        /// <summary>
        /// Perform an asynchronous HTTP (Ajax) request.
        /// </summary>
        /// <param name="url"></param>
        public static JQXmlHttpRequest Ajax(string url)
        {
            return null;
        }

        /// <summary>
        /// Perform an asynchronous HTTP (Ajax) request.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="settings"></param>
        public static JQXmlHttpRequest Ajax(string url, AjaxSettings settings)
        {
            return null;
        }

        /// <summary>
        /// Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
        /// </summary>
        /// <param name="callback">string function(settings, originalSettings, jqXHR)
        /// <para>Can redirect a request to another dataType by returning that dataType.</para>
        /// </param>
        public static void AjaxPrefilter(Func<string, AjaxSettings, AjaxSettings, JQXmlHttpRequest> callback)
        {
        }

        /// <summary>
        /// Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
        /// </summary>
        /// <param name="dataType">The prefilter will be only be applied to requests with the indicated dataTypes.</param>
        /// <param name="callback">string function(settings, originalSettings, jqXHR)
        /// <para>Can redirect a request to another dataType by returning that dataType.</para>
        /// </param>
        public static void AjaxPrefilter(string dataType, Func<string, AjaxSettings, AjaxSettings, JQXmlHttpRequest> callback)
        {
        }

        /// <summary>
        /// Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
        /// </summary>
        /// <param name="callback">void function(settings, originalSettings, jqXHR)
        /// <para>Can redirect a request to another dataType by returning that dataType.</para>
        /// </param>
        public static void AjaxPrefilter(Action<AjaxSettings, AjaxSettings, JQXmlHttpRequest> callback)
        {
        }

        /// <summary>
        /// Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
        /// </summary>
        /// <param name="dataType">The prefilter will be only be applied to requests with the indicated dataTypes.</param>
        /// <param name="callback">void function(settings, originalSettings, jqXHR)        
        /// </param>
        public static void AjaxPrefilter(string dataType, Action<AjaxSettings, AjaxSettings, JQXmlHttpRequest> callback)
        {
        }

        /// <summary>
        /// Set default values for future Ajax requests.
        /// </summary>
        /// <param name="settings"></param>
        public static void AjaxSetup(AjaxSettings settings)
        {
        }

        /// <summary>
        /// Load data from the server using a HTTP GET request.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static JQXmlHttpRequest Get(string url)
        {
            return null;
        }        

        /// <summary>
        /// Load data from the server using a HTTP GET request.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="success">void function(data, status, jqXHR)</param>
        /// <returns></returns>
        public static JQXmlHttpRequest Get(string url, Action<object, string, JQXmlHttpRequest> success)
        {
            return null;
        }

        /// <summary>
        /// Load data from the server using a HTTP GET request.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="data"></param>
        /// <param name="success">void function(data, status, jqXHR)</param>
        /// <returns></returns>
        public static JQXmlHttpRequest Get(string url, object data, Action<object, string, JQXmlHttpRequest> success)
        {
            return null;
        }

        /// <summary>
        /// Load data from the server using a HTTP GET request.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="data"></param>
        /// <param name="success">void function(data, status, jqXHR)</param>
        /// <param name="dataType"></param>
        /// <returns></returns>
        public static JQXmlHttpRequest Get(string url, object data, Action<object, string, JQXmlHttpRequest> success, string dataType)
        {
            return null;
        }

        /// <summary>
        /// Load JSON-encoded data from the server using a GET HTTP request.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static JQXmlHttpRequest GetJSON(string url)
        {
            return null;
        }

        /// <summary>
        /// Load JSON-encoded data from the server using a GET HTTP request.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="success">void function(data, status, jqXHR)</param>
        /// <returns></returns>
        public static JQXmlHttpRequest GetJSON(string url, Action<object, string, JQXmlHttpRequest> success)
        {
            return null;
        }

        /// <summary>
        /// Load JSON-encoded data from the server using a GET HTTP request.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="data"></param>
        /// <param name="success">void function(data, status, jqXHR)</param>
        /// <returns></returns>
        public static JQXmlHttpRequest GetJSON(string url, object data, Action<object, string, JQXmlHttpRequest> success)
        {
            return null;
        }

        /// <summary>
        /// Load a JavaScript file from the server using a GET HTTP request, then execute it.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static JQXmlHttpRequest GetScript(string url)
        {
            return null;
        }

        /// <summary>
        /// Load a JavaScript file from the server using a GET HTTP request, then execute it.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="success">void function(script, status, jqXHR)</param>
        /// <returns></returns>
        public static JQXmlHttpRequest GetScript(string url, Action<string, string, JQXmlHttpRequest> success)
        {
            return null;
        }

        /// <summary>
        /// Load data from the server using a HTTP POST request.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static JQXmlHttpRequest Post(string url)
        {
            return null;
        }

        /// <summary>
        /// Load data from the server using a HTTP POST request.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="success">void function(data, status, jqXHR)</param>
        /// <returns></returns>
        public static JQXmlHttpRequest Post(string url, Action<object, string, JQXmlHttpRequest> success)
        {
            return null;
        }

        /// <summary>
        /// Load data from the server using a HTTP POST request.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="data"></param>
        /// <param name="success">void function(data, status, jqXHR)</param>
        /// <returns></returns>
        public static JQXmlHttpRequest Post(string url, object data, Action<object, string, JQXmlHttpRequest> success)
        {
            return null;
        }

        /// <summary>
        /// Load data from the server using a HTTP POST request.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="data"></param>
        /// <param name="success">void function(data, status, jqXHR)</param>
        /// <param name="dataType"></param>
        /// <returns></returns>
        public static JQXmlHttpRequest Post(string url, object data, Action<object, string, JQXmlHttpRequest> success, string dataType)
        {
            return null;
        }
    }
}
